<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://eureka.yigolden.net/stringutils/sutaglib/1.0" prefix="su"%>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->

    <title>问卷中心</title>

    <!-- Bootstrap core CSS -->
    <link href="<%=request.getContextPath() %>/static/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="<%=request.getContextPath() %>/static/css/summernote.css" rel="stylesheet">
    <link href="<%=request.getContextPath() %>/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="<%=request.getContextPath() %>/static/js/html5shiv.min.js"></script>
      <script src="<%=request.getContextPath() %>/static/js/respond.min.js"></script>
    <![endif]-->
    
    <script src="<%=request.getContextPath() %>/static/js/jquery.min.js" ></script>
    <script src="<%=request.getContextPath() %>/static/js/bootstrap.min.js"></script>
	<script src="<%=request.getContextPath() %>/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.min.js"></script>
  </head>

  <body>
  <jsp:include page="../Common/navHeader.jsp"></jsp:include>
  <div class="container">
  
  	<br/><br/><br/>
	<h1 style="font-family:华文行楷;" >好室友<small>网</small> </h1>
    <div class="row">
    	
		<div class="col-sm-3">
		</div>
		<div class="col-sm-6">
			<jsp:include page="navHeader.jsp"></jsp:include>
			<br/><br/>
			<%request.setAttribute("tag", "addquestionnaire"); %>
			<form id="addquestionnaireForm" class="form-horizontal" method="post" action="">
		        <input type="hidden" name="action" value="posting" />    
		         
		  		<div class="form-group">
			  		<div class="col-sm-3">
			  			<label>问卷主题：</label>
					</div>
					<div class="col-sm-9">
			    	</div>
				</div>  
		  		
		  		<div class="form-group">
		  			<div class="col-sm-12">
		  				<div class="summernote" id="summernote"></div>
		  				<input type="hidden" id="subject" name="subject" value="" />
		  			</div>
		  		</div>

		  		<div class="form-group">
			  		<div class="col-sm-3">
			  				<label>开始时间：</label>
			  		</div>
			  		<div class="col-sm-6 input-group date form_datetime">
					    <input class="form-control" size="16" type="text" id="starttime" name="starttime" value="" readonly>
					    <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
					</div>
				</div> 
				
				<div class="form-group">
			  		<div class="col-sm-3">
			  				<label>结束时间：</label>
			  		</div>
			  		<div class="col-sm-6 input-group date form_datetime">
					    <input class="form-control" size="16" type="text" id="endtime" name="endtime" value="" readonly>
					    <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
					</div>
			
					<script type="text/javascript">
					    $(".form_datetime").datetimepicker({
					        format: "yyyy-mm-dd hh:ii",
					        autoclose: true,
					        todayBtn: true,
					        pickerPosition: "bottom-left"
					    });
					</script> 
				</div> 

		  		<div class="form-group" style="margin-top:50px">
		    		<div class="col-xs-12">
		      			<div class="col-xs-6 text-right">
		     				 <button type="submit" class="btn btn-success">确认提交</button>
		     		    </div>
		      			<div class="col-xs-6 text-left">
		      				<button type="reset" class="btn btn-warning">重新填写</button>
		      			</div>	
		    		</div>
		    		
		    		<div class="col-xs-12">
		    		 <c:if test="${errorCode eq 0 }">
		          		<div class="alert alert-warning" role="alert" id="alert-warning">创建失败！</div>
		        	</c:if>
		
		        	<c:if test="${successCode eq 1 }">
		          		<div class="alert alert-warning" role="alert" id="alert-warning">创建成功！</div>
		        	</c:if>  
		        	</div>
		  		</div>
		        
		        
		        <input type="hidden" name="referrer" value="${su:encodeUriComponent(referer) }" />
	        
	      	</form>
	      	
      </div>
      <div class="col-sm-3"></div>
     </div>

    </div>

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="<%=request.getContextPath() %>/static/js/ie10-viewport-bug-workaround.js"></script>
	<script src="<%=request.getContextPath() %>/static/js/summernote.min.js" ></script>
	<script src="<%=request.getContextPath() %>/static/js/summernote-zh-CN.js" ></script>
	
	<script>
		function validateaddquestionnaireForm(){	
				
			if($('#summernote').summernote('isEmpty')){
				alert("主题不能为空！");
				return false;
			}
			if($('#summernote').summernote('code').length>10000){
				alert("内容超过10000，请适当精简！");
				return false;
			}
			if($('#starttime').val()==""){
				alert("请填写开始时间！");
				$('#starttime').focus();
				return false;
			}
			if($('#endtime').val()==""){
				alert("请填写结束时间！");
				$('#endtime').focus();
				return false;
			}
			return true;
		}
	
		$(document).ready(function() {
		    $('#summernote').summernote({
		        height: 100,
		        minHeight: 100,
		        lang: 'zh-CN',
		        placeholder: '请在这里填写问卷名！',
		        toolbar: [
		                  ['style', ['bold', 'italic', 'underline', 'clear']],
		                  ['font', ['strikethrough', 'superscript', 'subscript']],
		                  ['color', ['color']],
		                  ['para', ['ul', 'ol', 'paragraph']]
		                ]
		    });
		    
		    $("#addquestionnaireForm").submit(function() {
		    	if (!validateaddquestionnaireForm())
		    		return false;
		    	$("#subject").val($('#summernote').summernote('code'));
		    	return true;
		    });		    

		});
		
		
	</script>
  </body>
</html>